<?php
namespace app\admin\controller;
use app\common;
use think\Controller;
use think\Session;
use think\Request;
use think\File;
use think\model;

class About extends common
{

        //加载修改页
    public function index()
    {
        //查找要修改的数据
        $info = db("about")->where("id",1)->find();
        $this->assign('loginname', $this->login());
        $this->assign('row', $info);
        return $this->fetch("about/edit");
    }

    //将修改数据的数据保存到数据库

    public function update($id)
    {
        $data['name'] = $_POST['name'];
        $data['wx_name'] = $_POST['wx_name'];
        $data['mobile'] = $_POST['mobile'];
        $sql = db("about")->where("id", $id)->update($data);
        if ($sql > 0) {
            $this->success("修改成功", "about/index");
        } else {
            $this->error("修改失败");
        }

    }


    //删除数据
    public function delete($id)
    {
        $list = db("about")->find($id);
        if ($list > 0) {
            $sql = db('about')->where("id", $id)->delete();
            if ($sql) {
                $this->success("删除成功", "about/index");
            } else {
                $this->error("删除失败");
            }
        }
    }

}

